package com.landeb.shop.huo.adapter;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.landeb.shop.R;
import com.landeb.shop.huo.bean.BeanCommentFrag;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * Created by blade on 2017/9/26.
 */

public class CommentFragAdapter extends BaseQuickAdapter<BeanCommentFrag.DataBean.ListBean, BaseViewHolder> {

    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");

    private Context mContext;

    public CommentFragAdapter(int layoutResId, List<BeanCommentFrag.DataBean.ListBean> data, Context context) {
        super(layoutResId, data);
        mContext = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, BeanCommentFrag.DataBean.ListBean item) {

        String time = simpleDateFormat.format(new Date(Long.parseLong(item.getComment_time()) * 1000L));


        helper.setText(R.id.item_comment_frag_tv_userName, item.getNickname())
                .setText(R.id.item_comment_frag_tv_time, time)
                .setText(R.id.item_comment_frag_tv_comment, item.getComment());

        Glide.with(mContext).load("http://www.landeb.com/index.php/Api/Public/user_head/uid/"+item.getUid()).into((ImageView) helper.getView(R.id.item_comment_frag_iv_headPic));
    }
}
